/**********************************************************
 * ReviewSentInvoicesReportAction.java
 * Created by Ashutosh
 * Last modified Date: Sep 18, 2008 10:49:34 AM by Ashutosh
 * Revision: <svn revision #>
 * Version : 0.1
 * Copyright (c) 2008 - 2009 cyberThink Infotech Pvt. Ltd., All rights reserved.
 **********************************************************/

package com.printeverywhere.action;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

import com.printeverywhere.delegator.CommonFunctionDelegator;
import com.printeverywhere.dto.AuctionInvoices;
import com.printeverywhere.dto.Transactions;
import com.printeverywhere.util.DateUtil;

/**
 * The Class ReviewSentInvoicesReportAction.
 */
public class ReviewSentInvoicesReportAction extends AdminEngineManagement {

	/** Logger for this class. */
	private static final Logger logger = Logger.getLogger(ReviewSentInvoicesReportAction.class);

	private List<AuctionInvoices> auctionInvoicesList = new ArrayList<AuctionInvoices>();

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	private Date startDate;

	private Date endDate;

	private int overdue = 0;

	/* (non-Javadoc)
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	public String execute() throws Exception{
		if (logger.isDebugEnabled()) {
			logger.debug("execute() - start"); //$NON-NLS-1$
		}

		if(startDate != null && endDate != null) {
			List<Criterion> criterionList = new ArrayList<Criterion>();
			criterionList.add(Restrictions.between("date", startDate, endDate));

			if(overdue != 0)
				criterionList.add(Restrictions.eq("overdue", overdue));
			auctionInvoicesList = (List<AuctionInvoices>) CommonFunctionDelegator.getObjectsByCriterion(criterionList, null, null, AuctionInvoices.class);

		} else {
			auctionInvoicesList = (List<AuctionInvoices>) CommonFunctionDelegator.getAllfromtable(AuctionInvoices.class.getName());
		}

		if (logger.isDebugEnabled()) {
			logger.debug("execute() - end"); //$NON-NLS-1$
		}
		return SUCCESS;
	}

	public List<AuctionInvoices> getAuctionInvoicesList() {
		return auctionInvoicesList;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public int getOverdue() {
		return overdue;
	}

	public void setOverdue(int overdue) {
		this.overdue = overdue;
	}
}